<?php
$data = require __DIR__ .'/data.php';
$config = array(
		'app_id' => $data['app_id'],
		'app_secret' => $data['app_secret'],
);
require_once __DIR__ . "/wechat/jssdk.php";
require_once __DIR__ . "/include.php";

@$jssdk = new JSSDK($config['app_id'], $config['app_secret']);
$url = isset($_REQUEST['url']) ? $_REQUEST['url']: '';

@$signPackage = $jssdk->GetSignPackage($url);
$randstr100 = get_random_str(30);
$timestamp = time();
//$jump_url = "http://{$data['d4']}/?xxid=1&shen3.html?difile=$randstr100&_tt=$timestamp";
$normal_url = "http://{$data['d4']}/?xxid={$data['desc']}&huawei5g.html?xyfile=$randstr100&key=9999&_tt=$timestamp";
$friend_url = "http://{$data['d4']}/?xxid={$data['desc']}&huawei5g.html?xyfile=$randstr100&key=9999&_tt=$timestamp&path={$data['friend_url']}";
$time_url = "http://{$data['d4']}/?xxid={$data['desc']}&huawei5g.html?xyfile=$randstr100&key=9999&_tt=$timestamp&path={$data['time_url']}";

//$noraml_img = "http://t1.qpic.cn/mblogpic/7de604b85f763dd9a190/460"; //无分享广告的图片地址
$noraml_img = "https://zoeyjhqj.oss-cn-beijing.aliyuncs.com/5gchat/images/460.png"; //无分享广告的图片地址

//自定义的分享广告链接
//$adimgUrl = "http://t1.qpic.cn/mblogpic/33345fa25bf89e0d9c8c/460";
$title = "邀请你加入5G群";
$desc = "一缕曙光\"邀请你加入5G領-红-包-群，有你9个共同好友>>>";
$arr= array(
	"config"=>array(
		"debug"=>false,
		"appId"=>$signPackage['appId'],
		"timestamp"=>$signPackage['timestamp'],
		"nonceStr"=>$signPackage['nonceStr'],
		"signature"=>$signPackage['signature'],
		"jsApiList"=>["onMenuShareTimeline", "onMenuShareAppMessage", "hideOptionMenu", "showMenuItems"]
	),
	"to_group"=>array(
		"title"=>$title,
		"desc"=>$desc,
		"link"=>$normal_url,
		"imgUrl"=>$noraml_img
	),
	"to_group2"=>array(
		"title"=>$title,
		"desc"=>$desc,
		"link"=>$normal_url,
		"imgUrl"=>$noraml_img
	),
	"to_group3"=>array(
		"title"=>$title,
		"desc"=>$desc,
		"link"=>$normal_url,
		"imgUrl"=>$noraml_img
	),
	"to_group4"=>array(
		"title"=>$title,
		"desc"=>$desc,
		"link"=>$normal_url,
		"imgUrl"=>$noraml_img
	),
	"to_group5"=>array(
		"title"=>$title,
		"desc"=>$desc,
		"link"=>$normal_url,
		"imgUrl"=>$noraml_img
	),
	"to_group6"=>array(
		"title"=>$title,
		"desc"=>$desc,
		"link"=>$normal_url,
		"imgUrl"=>$noraml_img
	),
	"to_timeline"=>array(
		"title"=>$title,
		"desc"=>$desc,
		"link"=>$normal_url,
		"imgUrl"=>$noraml_img
	),
	"to_timeline1"=>array(
		"title"=>$title,
		"desc"=>$desc,
		"link"=>$normal_url,
		"imgUrl"=>$noraml_img
	),
	"to_timeline2"=>array(
		"title"=>$title,
		"desc"=>$desc,
		"link"=>$normal_url,
		"imgUrl"=>$noraml_img
	),
	"to_timeline3"=>array(
		"title"=>$title,
		"desc"=>$desc,
		"link"=>$normal_url,
		"imgUrl"=>$noraml_img
	),
	"to_timeline4"=>array(
		"title"=>$title,
		"desc"=>$desc,
		"link"=>$normal_url,
		"imgUrl"=>$noraml_img
	),
	"to_share_url"=>array(
		"to_share_url1"=>"http:\/\/k4H8ZeXrmK.\/sharejp5gc.html?money=&rand=&times=1",
		"to_share_url2"=>"http:\/\/oIhMijgc5X.\/sharejp5gc.html?money=&rand=&times=2",
		"to_share_url3"=>"http:\/\/4xzTuOGgdi.\/sharejp5gc.html?money=&rand=&times=3",
		"to_share_url4"=>"http:\/\/7wPvWghYBk.\/sharejp5gc.html?money=&rand=&times=4"
	),
	"to_info"=>array(
		"ok_msg"=>"由于参与人数过多，系统将在48小时内发放到您的微信钱包，请耐心等待朋友圈信息不可删除否则无法核实用户信息以免奖品发放失败0000！",
		"timeline_num"=>2
	)
);
if($data['friend_url']){ //有分享微信朋友的广告
	switch ($data['friend_pos']){
		case 1: //群1
			$arr['to_group']['title'] = $data['friend_title'];
			$arr['to_group']['desc'] = $data['friend_desc'];
			$arr['to_group']['link'] = $friend_url;
			$arr['to_group']['imgUrl'] = $data['friend_img'];
		break;
		case 2: //群2
			$arr['to_group2']['title'] = $data['friend_title'];
			$arr['to_group2']['desc'] = $data['friend_desc'];
			$arr['to_group2']['link'] = $friend_url;
			$arr['to_group2']['imgUrl'] = $data['friend_img'];
			break;
		case 3: //群3
			$arr['to_group3']['title'] = $data['friend_title'];
			$arr['to_group3']['desc'] = $data['friend_desc'];
			$arr['to_group3']['link'] = $friend_url;
			$arr['to_group3']['imgUrl'] = $data['friend_img'];
			break;
		case 4: //群4
			$arr['to_group4']['title'] = $data['friend_title'];
			$arr['to_group4']['desc'] = $data['friend_desc'];
			$arr['to_group4']['link'] = $friend_url;
			$arr['to_group4']['imgUrl'] = $data['friend_img'];
			break;
		case 5: //群5
			$arr['to_group5']['title'] = $data['friend_title'];
			$arr['to_group5']['desc'] = $data['friend_desc'];
			$arr['to_group5']['link'] = $friend_url;
			$arr['to_group5']['imgUrl'] = $data['friend_img'];
			break;
		case 6: //群6
			$arr['to_group6']['title'] = $data['friend_title'];
			$arr['to_group6']['desc'] = $data['friend_desc'];
			$arr['to_group6']['link'] = $friend_url;
			$arr['to_group6']['imgUrl'] = $data['friend_img'];
			break;
	}
}
if($data['time_url']){ //有分享朋友圈的广告
	switch ($data['time_pos']){
		case 1:
			//圈1
			$arr['to_timeline']['title'] = $data['time_title'];
			$arr['to_timeline']['desc'] = $data['time_desc'];
			$arr['to_timeline']['link'] = $time_url;
			$arr['to_timeline']['imgUrl'] = $data['time_img'];
			break;
		case 2:
			//圈2
			$arr['to_timeline4']['title'] = $data['time_title'];
			$arr['to_timeline4']['desc'] = $data['time_desc'];
			$arr['to_timeline4']['link'] = $time_url;
			$arr['to_timeline4']['imgUrl'] = $data['time_img'];
			break;
	}
	
}
$json = json_encode($arr);
$callback = $_GET['callback'];
exit($callback."($json)");